package com.sl;


import com.sl.util.IdWorker;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableScheduling;
import tk.mybatis.spring.annotation.MapperScan;

@EnableScheduling//开启定时器
@SpringBootApplication
@MapperScan(basePackages = "com.sl.mapper")
public class Application {
    //机器号
    @Value("${workerId}")
    //种子
    private Long workerId;
    @Value("${datacenterId}")
    private Long datacenterId;

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    //初始化ID算法生成器。雪花算法。交给spring
    @Bean
    public IdWorker initIdworker() {
        return new IdWorker(workerId, datacenterId);
    }

}
